package com.tzm.gaflow.strategy;


import com.tzm.gaflow.strategy.route.TaskExecuteAccept;
import com.tzm.gaflow.strategy.route.TaskExecuteBack;
import com.tzm.gaflow.strategy.route.TaskExecuteClose;

/**
 * Created by tzm
 */
public enum TaskExecuteStrategyEnum {

    RESULT_ACCEPT("RESULT_ACCEPT", new TaskExecuteAccept()),
    RESULT_CLOSE("RESULT_CLOSE", new TaskExecuteClose()),
    RESULT_BACK("RESULT_BACK", new TaskExecuteBack());


    TaskExecuteStrategyEnum(String title, TaskExecuteRoute router) {
        this.title = title;
        this.router = router;
    }

    private String title;
    private TaskExecuteRoute router;

    public String getTitle() {
        return title;
    }

    public TaskExecuteRoute getRouter() {
        return router;
    }

    public static TaskExecuteStrategyEnum match(String name, TaskExecuteStrategyEnum defaultItem) {
        if (name != null) {
            for (TaskExecuteStrategyEnum item : TaskExecuteStrategyEnum.values()) {
                if (item.name().equals(name)) {
                    return item;
                }
            }
        }
        return defaultItem;
    }

}
